import React from 'react'
import { $pre } from "../../../../http/http";
import { Tabs } from 'antd-mobile'
import { withRouter } from 'react-router-dom'
import "./Goods.less"
 function Goods(props) {
  let { goods, n, onChangeN } = props
  let goodsList=["热门商品", "猜你喜欢", "全部商品"];
  return (

    <div className='goods'>
      <Tabs
     onChange={key=>onChangeN(key)}
      >
        {goodsList.map((item, index) => {
          return <Tabs.Tab 
          title={item} 
          key={index}>
            {goods.length == 0 ? <div>暂无数据</div> :
              <div >
                {
                  goods[n].content.map((i, idx) => {
                    return <div 
                    className='goods_item' 
                    key={idx}  
                    onClick={() => {props.history.push(`/detail/${i.id}/1`)}}>
                      <img className='goods_shop_img' src={$pre + i.img} alt={i.goodsname} />
                      <h2>商品名称:{i.goodsname}</h2>
                      <div>原价：{i.price}</div>
                      <div>现价：{i.market_price}</div>
                    </div>
                  })
                }
              </div>
            }
          </Tabs.Tab>
        })}
      </Tabs>
    </div>
  )
}
export default withRouter(Goods)

